#include <iostream>
#include <algorithm>

using namespace std;

void selectionSort(int arr[], int n) {
    for (int i = 0; i < n; ++i) {
        //寻找[ｉ，n)区间里的最小值
        int minIndex = i;
        for (int j = i; j < n; ++j) {
            if (arr[j] < arr[minIndex])
                minIndex = j;
        }

        swap(arr[i], arr[minIndex]);
    }
}

int main() {
    int arr[10] = {10,9,8,7,6,5,4,3,2,1};
    selectionSort(arr, 10);
    for (int i = 0; i < 10; ++i) {
        std::cout << arr[i] << " ";
    }

    return 0;
}